﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SistemaAcademicoBLL.Managers;
using SistemaAcademicoBO.Entities;
using SistemaAcademicoDAL;

namespace SistemaAcademicoBLL
{
    public class ApplicationFacade
    {
        #region FIELDS
        SubjectManager subjectManager;
        DegreeCourseManager degreeCourseManager;
        ProfessorManager professorManager;
        ProfessorSubjectManager professorSubjectManager;
        SubjectInDegreeCourseManager subjectInDegreeCourseManager;
        IdentCurrentManager identCurrentManager;
        UserManager userManager;
        StudentManager studentManager;
        #endregion

        #region CONSTRUCTOR
        public ApplicationFacade()
        {
            subjectManager = new SubjectManager();
            degreeCourseManager = new DegreeCourseManager();
            professorManager = new ProfessorManager();
            professorSubjectManager = new ProfessorSubjectManager();
            subjectInDegreeCourseManager = new SubjectInDegreeCourseManager();
            identCurrentManager = new IdentCurrentManager();
            userManager = new UserManager();
            studentManager = new StudentManager();
        }
        #endregion

        #region SUBJECT METHODS
        public Subject GetSubject(int id)
        {
            return subjectManager.GetSubject(id);
        }

        public List<Subject> GetAllSubjects()
        {
            return subjectManager.GetAllSubjects();
        }

        public void SetSubject(Subject subject)
        {
            subjectManager.SetSubject(subject);
        }

        public void RemoveSubject(int id)
        {
            subjectManager.RemoveSubject(id);
        }
        #endregion

        #region DEGREECOURSE METHODS
        public DegreeCourse GetDegreeCourse(int id)
        {
            return degreeCourseManager.GetDegreeCourse(id);
        }

        public List<DegreeCourse> GetAllDegreeCourses()
        {
            return degreeCourseManager.GetAllDegreeCourses();
        }

        public void SetDegreeCourse(DegreeCourse degreeCourse)
        {
            degreeCourseManager.SetDegreeCourse(degreeCourse);
        }

        public void RemoveDegreeCourse(int id)
        {
            degreeCourseManager.RemoveDegreeCourse(id);
        }
        #endregion

        #region PROFESSOR METHODS
        public Professor GetProfessor(int id)
        {
            return professorManager.GetProfessor(id);
        }

        public List<Professor> GetAllProfessors()
        {
            return professorManager.GetAllProfessors();
        }

        public void SetProfessor(Professor professor)
        {
            professorManager.SetProfessor(professor);
        }

        public void RemoveProfessor(int id)
        {
            professorManager.RemoveProfessor(id);
        }
        #endregion

        #region PROFESSORSUBJECT METHODS
        public ProfessorSubject GetProfessorSubject(int professorId, int SubjectId)
        {
            return professorSubjectManager.GetProfessorSubject(professorId, SubjectId);
        }

        public List<ProfessorSubject> GetAllProfessorsSubjects()
        {
            return professorSubjectManager.GetAllProfessorSubjects();
        }

        public List<ProfessorSubject> GetAllProfessorsSubjectsBySubjectId(int subjectId)
        {
            List<ProfessorSubject> allProfessorSubject = professorSubjectManager.GetAllProfessorSubjects();
            List<ProfessorSubject> returnList = new List<ProfessorSubject>();
            foreach (ProfessorSubject professorSubject in allProfessorSubject)
            {
                if (professorSubject.SubjectId == subjectId)
                {
                    returnList.Add(professorSubject);
                }
            }
            return returnList;
        }

        public List<ProfessorSubject> GetAllProfessorsSubjectsByProfessorId(int professorId)
        {
            List<ProfessorSubject> allProfessorSubject = professorSubjectManager.GetAllProfessorSubjects();
            List<ProfessorSubject> returnList = new List<ProfessorSubject>();
            foreach (ProfessorSubject professorSubject in allProfessorSubject)
            {
                if (professorSubject.ProfessorId == professorId)
                {
                    returnList.Add(professorSubject);
                }
            }
            return returnList;
        }

        public void SetProfessorSubject(ProfessorSubject professorSubject)
        {
            professorSubjectManager.SetProfessorSubject(professorSubject);
        }

        public void RemoveProfessorSubject(int professorId, int SubjectId)
        {
            professorSubjectManager.RemoveProfessorSubject(professorId, SubjectId);
        }
        #endregion

        #region SUBJECTINDEGREECOURSE METHODS
        public SubjectInDegreeCourse GetSubjectInDegreeCourse(int id)
        {
            return subjectInDegreeCourseManager.GetSubjectInDegreeCourse(id);
        }

        public List<SubjectInDegreeCourse> GetAllSubjectInDegreeCourses()
        {
            return subjectInDegreeCourseManager.GetAllSubjectInDegreeCourses();
        }

        public List<SubjectInDegreeCourse> GetAllSubjectInDegreeCourses(int degreeCourseId)
        {
            List<SubjectInDegreeCourse> list = subjectInDegreeCourseManager.GetAllSubjectInDegreeCourses();
            List<SubjectInDegreeCourse> list2 = new List<SubjectInDegreeCourse>();
            foreach (SubjectInDegreeCourse subjectInDegreeCourse in list)
            {
                if (subjectInDegreeCourse.DegreeCourseId == degreeCourseId)
                {
                    list2.Add(subjectInDegreeCourse);
                }
            }
            return list2;
        }

        public void SetSubjectInDegreeCourse(SubjectInDegreeCourse subjectInDegreeCourse)
        {
            subjectInDegreeCourseManager.SetSubjectInDegreeCourse(subjectInDegreeCourse);
        }

        public void RemoveSubjectInDegreeCourse(int id)
        {
            subjectInDegreeCourseManager.RemoveSubjectInDegreeCourse(id);
        }
        #endregion

        #region IDENTCURRENT METHODS
        public int GetIdentCurrent(string tbName)
        {
            return identCurrentManager.getIdentCurrent(tbName);
        }
        #endregion

        #region USER METHODS
        public User GetUser(int id)
        {
            return userManager.GetUser(id);
        }

        public List<User> GetAllUsers()
        {
            return userManager.GetAllUsers();
        }

        public void SetUser(User user)
        {
            userManager.SetUser(user);
        }

        public void RemoveUser(int id)
        {
            userManager.RemoveUser(id);
        }

        public User GetUserByUserLogin(string userLogin)
        {
           return userManager.GetUserByUserLogin(userLogin);
        }
        #endregion

        #region STUDENT METHODS
        public Student GetStudent(Guid id)
        {
            return studentManager.GetStudent(id);
        }

        public List<Student> GetAllStudents()
        {
            return studentManager.GetAllStudents();
        }

        public void SetStudent(Student student)
        {
            studentManager.SetStudent(student);
        }

        public void RemoveStudent(int id)
        {
            studentManager.RemoveStudent(id);
        }
        #endregion
    }
}
